#coding=cp936
import os
import shutil

def view_all_exts(dirname):
    exts=['.dcu','.~pas','.~dfm','.bat','.ddp','.~ddp','.~dfm','.~dpr','~bpg','.log']
    
    if os.path.isfile(dirname):
        #print dirname
        #print dirname[-4:]
        exta=os.path.splitext(dirname)[1]
        #print exta
        if exta.lower() in exts:
            #print exta.lower()
            print dirname.lower()
            os.remove(dirname)
            
        
    elif os.path.isdir(dirname):
        for item in os.listdir(dirname):
            itemsrc = os.path.join(dirname,item)
            view_all_exts(itemsrc)
         
if __name__ == "__main__":
    #dirname = r'D:\Work\PRMSY'
    #filname = r'E:\quickdisk\Delphi\Delphi_Pack\Class_KzUtils.pas'

    dirname  =  os.getcwd()
    print 'current dirname:'+dirname
    
    truepassword = r'kazarus0618'
    temppassword = raw_input('enter password:')
    #print temppassword
    if truepassword <> temppassword :
        sys.exit()
    print r'successful'

    print os.getcwd()
    
    view_all_exts(dirname)  
